#include "SMARTSESIO.h"

void SMARTSESSolutionPrint(FILE *fileHandler)
{
	//ToDo: Use Regulation To Output the Data in the Future
	
	//Now: Output all of the file
	//char* fileContent = SMARTNEW(char, 1024);
	//fscanf(fileHandler, "%s", fileContent);
	//printf("The solution data is :\n %s", fileContent);
}

void SMARTSESWriteToFile(double *X, double Y, int n, FILE *fileHandler)
{
	int i;
	fprintf(fileHandler, "\n/X/\n");
	for(i = 0; i < n; i++)
	{
		fprintf(fileHandler, "%g ",X[i]);
	}
	fprintf(fileHandler, "\n/Y/\n");
	fprintf(fileHandler, "%g\n", Y);
}

void SMARTSESWriteTitle(double *A, double *B, double *C, double *D, SES_SRC *s, int n, FILE *fileHandler)
{
	fprintf(fileHandler, "Version Information\n");
	fprintf(fileHandler, "n = %d\n", n);
	int i,j;
	if(A != NULL)
	{
		fprintf(fileHandler, "\n/A/\n");
		for(i = 0; i < n; i++)
			for(j = 0; j < n; j++)		
				fprintf(fileHandler, "%g ", A[i*n+j]);
	}
	if(B != NULL)
	{
		fprintf(fileHandler, "\n/B/\n");
		for(i = 0; i < n; i++)
			for(j = 0; j < n; j++)		
				fprintf(fileHandler, "%g ", B[i*n+j]);
	}
	if(C != NULL)
	{
		fprintf(fileHandler, "\n/C/\n");
		for(i = 0; i < n; i++)			
			fprintf(fileHandler, "%g ", C[i]);
	}
	if(D != NULL)
	{
		fprintf(fileHandler, "\n/D/\n");
		for(i = 0; i < n; i++)			
			fprintf(fileHandler, "%g ", D[i]);		
	}
	fprintf(fileHandler, "\n\n");
}

void SMARTSESSolutionShow(FILE *fileHandler)
{
	
}

void DebugSMARTSESStoreData(double *X, double Y, int n, int step, double hfactor, FILE *fileHandler)
{
	int i;
	
	fprintf(fileHandler, "%g ", step * hfactor);	
	fprintf(fileHandler, "%g ", Y);
	
	for(i = 0; i < n; i++)
	{
		fprintf(fileHandler, "%g ", X[i]);
	}
	fprintf(fileHandler, "\n");
}
